package com.zl.autocode.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zl.autocode.controller.base.AutocodeBaseController;
import com.zl.autocode.dto.autocode.project.ReqProjectAddDTO;
import com.zl.autocode.dto.autocode.project.ReqProjectDelDTO;
import com.zl.autocode.dto.autocode.project.ReqProjectDetailDTO;
import com.zl.autocode.dto.autocode.project.ReqProjectEditDTO;
import com.zl.autocode.dto.autocode.project.ReqProjectQueryDTO;
import com.zl.autocode.dto.autocode.project.ReqProjectStateDTO;
import com.zl.autocode.dto.autocode.project.ResProjectAddDTO;
import com.zl.autocode.dto.autocode.project.ResProjectDelDTO;
import com.zl.autocode.dto.autocode.project.ResProjectDetailDTO;
import com.zl.autocode.dto.autocode.project.ResProjectEditDTO;
import com.zl.autocode.dto.autocode.project.ResProjectQueryDTO;
import com.zl.autocode.dto.autocode.project.ResProjectStateDTO;
import com.zl.autocode.service.autocode.IProjectService;
import com.zl.common.dto.ReqDTO;
import com.zl.common.dto.ResDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 项目配置
 * @author ZL
 */
@Api(value="项目配置",tags ="项目配置")
@RestController("autocodeProjectController")
@RequestMapping("/autocode/project")
public class ProjectController extends AutocodeBaseController {

    @Autowired
    private IProjectService projectService;
    
    /**
     * 查询
     */
    @ApiOperation(value="项目配置-查询")
    @RequestMapping(value="/list", method = RequestMethod.POST)
    public ResDTO<ResProjectQueryDTO> listProject(@RequestBody ReqDTO<ReqProjectQueryDTO> reqInfo) throws Exception{
        ResProjectQueryDTO data = projectService.queryProjectList(reqInfo);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="项目配置-详情")
    @RequestMapping(value="/detail", method = RequestMethod.POST)
    public ResDTO<ResProjectDetailDTO> detailProject(@RequestBody ReqDTO<ReqProjectDetailDTO> reqInfo) throws Exception{
        ResProjectDetailDTO data = projectService.queryProjectDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="项目配置-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
        public ResDTO<ResProjectAddDTO> addProject(@RequestBody ReqDTO<ReqProjectAddDTO> reqInfo) throws Exception{
        ResProjectAddDTO data = projectService.insertProjectInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="项目配置-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
        public ResDTO<ResProjectEditDTO> editProject(@RequestBody ReqDTO<ReqProjectEditDTO> reqInfo) throws Exception{
        ResProjectEditDTO data = projectService.updateProjectInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="项目配置-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
        public ResDTO<ResProjectDelDTO> delProject(@RequestBody ReqDTO<ReqProjectDelDTO> reqInfo) throws Exception{
        ResProjectDelDTO data = projectService.deleteProjectInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="项目配置-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
        public ResDTO<ResProjectStateDTO> stateProject(@RequestBody ReqDTO<ReqProjectStateDTO> reqInfo) throws Exception{
        ResProjectStateDTO data = projectService.updateProjectState(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="项目配置-删除")
    @RequestMapping(value="/delProjectAndModule", method = RequestMethod.POST)
        public ResDTO<ResProjectDelDTO> delProjectAndModule(@RequestBody ReqDTO<ReqProjectDelDTO> reqInfo) throws Exception{
        ResProjectDelDTO data = projectService.deleteProjectAndModule(reqInfo);
        return successDATA(data); 
    }
}